#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author  : 邢建辉
# @Email   : xjh_0125@sina.com
# @Time    : 2021/12/28 10:33
# @Software: PyCharm
# @File    : l806_number_of_string.py


class Solution(object):
    def numberOfLines(self, widths, s):
        """
        :type widths: List[int]
        :type s: str
        :rtype: List[int]
        """
        line, remain = 1, 100
        for c in s:
            idx = ord(c) - 97
            # print(idx,c,remain,line)
            if remain < widths[idx]:
                remain = 100
                line += 1
            remain -= widths[idx]
        return [line, 100 - remain]


if __name__ == '__main__':
    s = Solution()
    widths = [4, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
    str = "bbbcccdddaaa"
    res = s.numberOfLines(widths, str)
    print(res)
